toastr.options = {
	"closeButton" : true,
	"debug" : false,
	"positionClass" : "toast-top-center",
	"onclick" : null,
	"showDuration" : "1000",
	"hideDuration" : "1000",
	"timeOut" : "2000",
	"extendedTimeOut" : "1000",
	"showEasing" : "swing",
	"hideEasing" : "linear",
	"showMethod" : "fadeIn",
	"hideMethod" : "fadeOut"
}

function formatTime(v){
	if(v.length>=14){
		return v.substring(0,4)+'-'+v.substring(4,6)+'-'+v.substring(6,8)+' '+v.substring(8,10)+":"+v.substring(10,12)+":"+v.substring(12,14);
	}
	
	return v;
}

$.ajaxSetup({
    type: 'POST',
    complete: function(xhr,status) {
        var sessionStatus = xhr.getResponseHeader('sessionStatus');
        if(sessionStatus == 'timeout') {
            var top = getTopWinow();
            var yes = confirm('由于您长时间没有操作,请重新登录');
            if (yes) {
                top.location.href = context+'/console/login';            
            }
        }
    }
});

/**
 * 在页面中任何嵌套层次的窗口中获取顶层窗口
 * @return 当前页面的顶层窗口对象
 */
function getTopWinow(){
    var p = window;
    while(p != p.parent){
        p = p.parent;
    }
    return p;
}